package com.siam.package_rider.feign;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.siam.package_common.entity.BasicResult;
import com.siam.package_merchant.entity.MerchantBillingRecord;
import com.siam.package_rider.entity.TbRiderBill;
import com.siam.package_rider.model.param.TbRiderBillParam;
import com.siam.package_rider.service.TbRiderBillService;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 提供给其他服务Feign客户端调用的用户模块相关接口
 */
@RestController
public class RiderBillFeignProvider implements RiderBillFeignApi {

    @Autowired
    private TbRiderBillService riderBillService;

    @Override
    public BasicResult insertSelective(TbRiderBill record) {
        riderBillService.save(record);
        return BasicResult.success();
    }

    @Override
    public BasicResult<List<TbRiderBill>> list(TbRiderBillParam param) {
        LambdaQueryWrapper<TbRiderBill> queryWrapper = new LambdaQueryWrapper<>();
        if(param.getType() != null){
            queryWrapper.eq(TbRiderBill::getType, param.getType());
        }
        if(CollectionUtils.isNotEmpty(param.getTypeList())){
            queryWrapper.in(TbRiderBill::getType, param.getTypeList());
        }
        if(param.getCoinType() != null){
            queryWrapper.eq(TbRiderBill::getCoinType, param.getCoinType());
        }
        if(param.getOriginOrderId() != null){
            queryWrapper.eq(TbRiderBill::getOriginOrderId, param.getOriginOrderId());
        }
        return BasicResult.success(riderBillService.list(queryWrapper));
    }
}